﻿Ext.define('app.prm.project.YearPhaseProjectView', {
    extend: 'Ext.window.Window',
    phaseId: 0,
    year: 0,
    autoScroll: true,
    modal: true,
    width: 850,
    height: 600,
    referenceHolder: true,
    buttonAlign: 'center',
    controller: 'project',
    requires: ['app.prm.project.ProjectController', 'app.prm.project.ViewModel'],
    initComponent: function () {
        var me = this;
        me.items = [
            me.getGrid()
        ];
        me.callParent();
    },
    getGrid: function () {
        var main = this;
        if (!this.gridpanel) {
            var dts = main.year + '-01-01';
            var dte = main.year + 1 + '-01-01';
            var store = Ext.create("app.ux.PagePrmStore", {
                url: '/api/services/app/project/GetAll?dts=' + dts + '&dte=' + dte + '&phaseStatus=0&phase=' + main.phaseId,
                groupField: 'customer',
                remoteSort: false,
                sorters: [{
                    //先按年龄降序  
                    property: 'customer',
                    direction: 'DESC'
                }]
            });
            this.gridpanel = Ext.create("Ext.grid.Panel", {
                store: store,
                features: [{ ftype: 'grouping' }],
                columns: [ 
                    { header: localize('ProjectName'), dataIndex: 'projectName' },
                    { header: localize('ProjectNo'), dataIndex: 'projectNo' },
                    { header: localize('ProductNo'), dataIndex: 'productNo' },
                    { header: localize('Customer'), dataIndex: 'customer', hidden: true },
                    { header: '项目经理', dataIndex: 'pm' },
                    //{ header: localize('CustomerCode'), dataIndex: 'customeCode' },
                    { header: '事业部', dataIndex: 'business' },
                    { header: localize('RdCenter'), dataIndex: 'rdCenter' },
                    { header: localize('Laboratory'), dataIndex: 'laboratory' },
                    { header: localize('PlanStartDate'), dataIndex: 'planStartDate' },
                    { header: localize('PlanEndDate'), dataIndex: 'planEndDate' },
                    { header: localize('RequiredCompleteDate'), dataIndex: 'targetEndDate' },
                    { header: '项目状态', dataIndex: 'projectStatus' }
                ],
                listeners: { 
                    rowdblclick: 'onYearPhaseProjectDbClick'
                }
            });
        }
        return this.gridpanel;
    }
})